package com.jht.pj.sys.service.impl;

import com.jht.pj.sys.dao.AdminDao;
import com.jht.pj.sys.pojo.Admin;
import com.jht.pj.sys.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;
    /*管理员登录*/
    @Override
    public String adminloginObject(String username, String password) {
        if("".equals(username)&&"".equals(password)){
            return "用户名和密码不能为空";
        }else if("".equals(username)){
            return "用户名不能为空";
        }else if("".equals(password)){
            return "密码不能为空";
        }
        String result=null;

        Admin admin=adminDao.adminlogin(username);
        try {
            if (password.equals(admin.getPassword())) {
                result = "登录成功";
            } else if (!password.equals(admin.getPassword())) {
                result = "密码错误，请重新输入";
            }
        }catch (Exception e){
            result="用户名或密码不正确";
        }
        return result;
    }
/*管理员找回密码*/
    @Override
    public String adminfindObject(String name) {
        if("".equals(name)){
            return "名字不能为空";
        }
        String result01=null;

        String psw=adminDao.adminfind(name);
        if(psw==null){
            result01="没有这个名字";
        }else {
            result01=psw;
        }
        return result01;
    }
}
